﻿package demos.performance.tweenTests
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.utils.Dictionary;
	
	import sweezy.anim.animate;
	import sweezy.anim.core.Animator;
	import sweezy.anim.core.IAnimation;
	import sweezy.anim.core.IAnimationManager;
	import sweezy.anim.core.IEasing;
	import sweezy.anim.core.IPropertyAnimation;
	import sweezy.anim.easing.Cubic;

	public class AnimTest extends TweenTest
	{

		private var _easing:IEasing = Cubic.easeIn;

		private var _tweenLookup:Dictionary = new Dictionary();

		public function AnimTest()
		{
			super("Anim", 4000);
		}

		override public function kill(targets:Array):void
		{
			var c:uint = targets.length, target:MovieClip;
			while (--c > -1)
			{
				_tweenLookup[target = targets[c]].pause();
				delete _tweenLookup[target];
			}
		}

		override public function tween(target:MovieClip, duration:Number, x:Number, y:Number, scaleX:Number, scaleY:Number, rotation:Number, delay:Number, ease:Function, onComplete:Function, onCompleteParams:Array):void
		{
			var anim:IPropertyAnimation = Animator.animate(target, duration * 1000, _easing, delay * 1000);
			anim.to("x", x);
			anim.to("y", y);
			anim.to("scaleX", scaleX);
			anim.to("scaleY", scaleY);
			anim.to("rotation", rotation);
			anim.onComplete = onComplete;
			anim.onCompleteParams = onCompleteParams;
			anim.start();
			_tweenLookup[target] = anim.start();
		}
	}
}